﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BackupLib
{
    using System.IO;

    public class FileAttrib
    {
        public string Name { get; private set; }

        private FileAttributes _fileAttributes;

        public long Length { get; set; }
        public DateTime CreationTime { get; set; }
        public DateTime LastWrite { get; set; }
        public DateTime LastRead { get; set; }

        public FileAttrib(string filename, uint dwFileAttributes)
        {
            Name = filename;
            _fileAttributes = (FileAttributes) dwFileAttributes;
        }

        public bool Archive
        {
            get { return ((_fileAttributes & FileAttributes.Archive) == FileAttributes.Archive); }
            set
            {
                if (value)
                {
                    _fileAttributes = _fileAttributes | FileAttributes.Archive;
                }
                else
                {
                    _fileAttributes = _fileAttributes & ~FileAttributes.Archive;
                    APIWrapper.SetFileAttributes(Name, _fileAttributes);
                }
            }
        }
        public bool Hidden
        {
            get { return ((_fileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden); }
        }
        public bool System
        {
            get { return ((_fileAttributes & FileAttributes.System) == FileAttributes.System); }
        }
        public bool Directory
        {
            get { return ((_fileAttributes & FileAttributes.Directory) == FileAttributes.Directory); }
        }
    }
}
